#pragma once
#include <sstream>

#include "basic.hpp"

class InstrPrinter
{
private:
    std::stringstream out_stream_;
    std::string outfile_name_;

public:
    InstrPrinter(std::string outfile_name="instructions.S");
    ~InstrPrinter();

    void add_instr(std::string opcode);
    void add_instr(std::string opcode,std::string instr_name);
    void add_line(std::string instr, std::string param0, std::string param1) {
        out_stream_ << instr << ' ' << param0 << ',' << param1 << " \\n\\t\\\n";
    }
    void add_line(std::string instr, std::string param0, std::string param1, std::string param2) {
        out_stream_ << instr << ' ' << param0 << ',' << param1 << '(' << param2 << ')' << " \\n\\t\\\n";
    }
    template <class T>
    void add_words(T&& words) {
        out_stream_ << words;
    }
    template <class T, class... Args>
    void add_words(T&& words, Args&& ... args) {
        out_stream_ << words;
        add_words(args...);
    }
    template <class... Args>
    void add_line(Args&& ... args) {
        add_words(args...);
        out_stream_ << '\n';
    }
    void to_file(std::string file_name);
    void to_stdout();
};